#encoding=utf-8

from  __future__ import print_function

import pandas as pd

filename = '../dataSets/chapter5/data/sales_data.xls'

data = pd.read_excel(filename, index_col=u'序号')

data[data == u'好'] = 1
data[data == u'是'] = 1
data[data == u'高'] = 1
data[data != 1] = -1

x = data.iloc[:,:3].as_matrix().astype(int)
y = data.iloc[:,3].as_matrix().astype(int)

from keras.models import Sequential
from keras.layers.core import Dense, Activation

model = Sequential()
model.add(Dense(3, 10))
model.add(Activation('relu'))
model.add(Dense(10, 1))
model.add(Activation('sigmoid'))

model.compile(loss='binary_crossentropy', optimizer='adam', class_mode = 'binary')
model.fit(x, y, nb_epoch=1000, batch_size=10)
yp = model.predict_classes(x).reshape(len(y))

from code import cm_plot
cm_plot(y, yp).show()






